﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Onlyle.Business;
using Onlyle.Model;
using System.Data;
using Onlyle.Models;
using Industry.Framework.Common.Helper;

namespace Onlyle.Controllers
{
    public class QingSongController : Controller
    {
        //
        // GET: /QingSong/
        string publicPage = "~/Views/qingsong/_qingsongpage.cshtml";
        QingSong_ArticleBLL articlebll = new QingSong_ArticleBLL();
        public ActionResult index()
        {
            if (Request.Path.Contains("wangzhai"))
            {
                AddHeadMeta("wangzhaiindex_title", "wangzhaiindex_keyword");
                return CreateQingSongPage(QingSongTypeEnum.网摘.ToString());
            }
            else
            {
                AddHeadMeta("qingsongindex_title", "qingsongindex_keyword");
                return CreateQingSongPage(QingSongTypeEnum.轻松.ToString());
            }
        }
        public ActionResult qingsongyike()
        {
            AddHeadMeta("qingsongyike_title", "qingsongyike_keyword");
            return CreateQingSongPage(QingSongTypeEnum.每日轻松一刻.ToString());
        }
        public ActionResult shentucao()
        {
            AddHeadMeta("shentucao_title", "shentucao_keyword");
            return CreateQingSongPage(QingSongTypeEnum.神吐槽.ToString());
        }
        public ActionResult fun()
        {
            AddHeadMeta("fun_title", "fun_keyword");
            return CreateQingSongPage(QingSongTypeEnum.FUN来了.ToString());
        }
        public ActionResult zhidao()
        {
            AddHeadMeta("zhidao_title", "zhidao_keyword");
            return CreateQingSongPage(QingSongTypeEnum.凤凰知道.ToString());
        }
        public ActionResult hujiemi()
        {
            AddHeadMeta("hujiemi_title", "hujiemi_keyword");
            return CreateQingSongPage(QingSongTypeEnum.狐揭秘.ToString());   
        }
        public ActionResult hqkanke()
        {
            AddHeadMeta("kanke_title", "kanke_keyword");
            return CreateQingSongPage(QingSongTypeEnum.今日环球侃客.ToString());
        }
        public ActionResult zhisheng()
        {
            AddHeadMeta("jinrizhisheng_title", "jinrizhisheng_keyword");
            return CreateQingSongPage(QingSongTypeEnum.今日之声.ToString());
        }
        public ActionResult dubao()
        {
            AddHeadMeta("dubao_title", "dubao_keyword");
            return CreateQingSongPage(QingSongTypeEnum.有报天天读.ToString());
        }
        public ActionResult laping()
        {
            AddHeadMeta("laping_title", "laping_keyword");
            return CreateQingSongPage(QingSongTypeEnum.热辣评.ToString());
        }
        public ActionResult xianzhidao()
        {
            AddHeadMeta("xianzhidao_title", "xianzhidao_keyword");
            return CreateQingSongPage(QingSongTypeEnum.先知道.ToString());
        }
        public ActionResult zuidasheng()
        {
            AddHeadMeta("zuidasheng_title", "zuidasheng_keyword");
            return CreateQingSongPage(QingSongTypeEnum.今日最大声.ToString());
        }


        ActionResult CreateQingSongPage(string type)
        {
            string pageNum = (Request.QueryString["p"] ?? "").ToString();
            List<E_QingSong_Article> ArticleList = articlebll.Select(pageNum, type);
            ViewBag.PageCount = articlebll.GetQingSongArticleCountByType(type);
            ViewBag.Type = type;
            return View(publicPage, ArticleList);
        }
        public ActionResult detail(string id)
        {
            E_QingSong_Article e_qingsong_article = articlebll.GetQingSongArticleByKey(id);
            return View(e_qingsong_article);
        }
        void AddHeadMeta(string title, string keywords)
        {
            string description = ConfigHelper.GetConfigString("gaoxiao_description");
            ViewData["title"] = ConfigHelper.GetConfigString(title);
            ViewData["keyword"] = ConfigHelper.GetConfigString(keywords);
            ViewData["description"] = description;
        }

    }
}
